/**********************************************************************************************************************
 *
 * Project:    mGameEngine
 * File:       configuration.h
 * Author:     karooolek
 * Created on: 2011-06-21
 *
 **********************************************************************************************************************/

#ifndef CONFIGURATION_H_
#define CONFIGURATION_H_

#include "map.h"
#include "string.h"

namespace mGameEngine
{

/**
 * Configuration.
 * Configuration is a set of named sections containing named string values.
 * This could be used for storing different values and shared between different objects.
 */
class Configuration
{
protected:
    /**
     * Configuration sections with values.
     */
    Map<String, Map<String, String> > _sections;

public:
    /**
     * Create new configuration.
     */
    Configuration(void);

    /**
     * Destroy configuration.
     */
    virtual ~Configuration(void);

    /**
     * Check if configuration has named section.
     * @param sectionName section name.
     * @return true if configuration has named section, false otherwise.
     */
    bool hasSection(const String &sectionName) const;

    /**
     * Add named section to configuration.
     * @param sectionName section name.
     */
    void addSection(const String &sectionName);
    
    /**
     * Remove named section from configuration.
     * @param sectionName section name.
     */
    void removeSection(const String &sectionName);

    /**
     * Get values for named section.
     * @param sectionName section name.
     * @return named section values, or empty map if section doesn't exist.
     */
    const Map<String, String> &getSectionValues(const String &sectionName) const;

    /**
     * Check if configuration has named value in specific section.
     * @param sectionName section name.
     * @param valueName value name.
     * @return true if specific section has named value, false if section doesn't exist or doesn't have value.
     */
    bool hasValue(const String &sectionName, const String &valueName) const;

    /**
     * Add named value to specific section. Value will be added only if section exists.
     * @param sectionName section name.
     * @param valueName value name.
     * @param value value.
     */
    void addValue(const String &sectionName, const String &valueName, const String &value);

    /**
     * Remove named value from specific section. Value will be removed only if section exists.
     * @param sectionName section name.
     * @param valueName value name.
     */
    void removeValue(const String &sectionName, const String &valueName);

    /**
     * Get named value from specific section.
     * @param sectionName section name.
     * @param valueName value name.
     * @return value, or empty string if specific section doesn't exists or doesn't have value.
     */
    const String &getValue(const String &sectionName, const String &valueName) const;
};

}

#endif // CONFIGURATION_H_
